﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SimpleData.Infrastructure.Utils;

namespace System
{
	/// <summary>
	/// 
	/// </summary>
	public static class InputValidationExtensions
	{
		public static IInputValidator<TValue> Throws<TValue>( this TValue value )
		{
			return InputValidator<TValue>.Create( value );
			//return new InputValue<TValue>() { Value = value };
		}


		public static TInput InvalidOperation<TInput>( this TInput input, string message, params object[] messageArgs )
			where TInput : IInputValidator
		{
			input.OverrideException( () => new InvalidOperationException( String.Format( message, messageArgs ) ) );
			return input;
		}

		//public static IInputValidator<TValue> InvalidOperation<TValue>( this InputValue<TValue> input, string message, params object[] messageArgs )
		//{
		//    var validator = input.Validator();

		//    validator.OverrideException( () => new InvalidOperationException( String.Format( message, messageArgs ) ) );
		//    return validator;
		//}

		//public static IInputValidator<TValue> ArgumentNull<TValue>( this InputValue<TValue> input, string parameterName )
		//{
		//    var validator = input.Validator();

		//    validator.OverrideException( () => new ArgumentNullException( parameterName ) );
		//    return validator;
		//}


		//internal static IInputValidator<TValue> Validator<TValue>( this InputValue<TValue> input )
		//{
		//    return InputValidator<TValue>.Create( input.Value );
		//}
	}

	/// <summary>
	/// 
	/// </summary>
	/// <typeparam name="TValue"></typeparam>
	//public struct InputValue<TValue>
	//{
	//    public TValue Value
	//    { get; internal set; }
	//}

}
